﻿@using Acme.Marketing.Data
@model IEnumerable<Acme.Marketing.Data.Newspaper>

@{
    ViewBag.Title = "ListNewspaper";
}

<h2>ListNewspaper</h2>

<p>
    @Html.ActionLink("Create New", "CreateNewspaper", "Home")
</p>
<table>
    <tr>
        <th>NewspaperId</th>
        <th>Publish Date</th>
        <th>Headline</th>
        <th>Advertisements</th>
    </tr>

    @foreach (Newspaper item in Model)
    {
        <tr>
            <td>
                @item.NewspaperId
            </td>
            <td>
                @item.PublishDate
            </td>
            <td>
                @item.Headline
            </td>
            <td>
                <table>
                    <tr>
                        <th></th>
                        <th></th>
                    </tr>
                    <tr>
                        @Html.ActionLink("Relate Ads", "RelateAds", "Home", new { id = item.NewspaperId }, null)

                        @foreach (Advertisement ad in item.Advertisements)
                        {
                            <td><input type="text" value="@ad.AdvertisementId" /></td>
                            <td>@ad.Contents</td>
                        }

                    </tr>
                </table>

            </td>
        </tr>
    }

</table>